home *** CD-ROM | disk | FTP | other *** search
/ CD Action 72 - Disc 2 / cdaction-72-2.iso / #dema / tux racer / tuxracer-win32-0.61a.exe / tuxracer-win32-0.61a / courses / course_idx.tcl
Text File  |  2001-01-24  |  5KB  |  184 lines

  1.  
  2. #
  3. # Procedure to get course name, author, and par time from course.tcl file.
  4. #
  5. proc get_course_info { } {
  6.     if [catch {open course.tcl r} fileId] {
  7.     puts stderr "Couldn't open course.tcl in [pwd]"
  8.     return {}
  9.     }
  10.  
  11.     set name ""
  12.     set author ""
  13.     set par_time ""
  14.  
  15.     while {[gets $fileId line] >= 0} {
  16.     regexp {tux_course_name *([^;]*)} $line match name
  17.     regexp {tux_course_author *([^;]*)} $line match author
  18.     regexp {tux_par_time *([^;]*)} $line match par_time
  19.  
  20.     if { $author != "" && $name != "" && $par_time != "" } {
  21.         break;
  22.     }
  23.     }
  24.  
  25.     if { $author == "" } {
  26.     set author "Unknown"
  27.     }
  28.  
  29.     if { $name == "" } {
  30.     set name "Unknown"
  31.     }
  32.  
  33.     if { $par_time == "" } {
  34.         set par_time 120.0
  35.     } 
  36.  
  37.     # Remove quotes around strings, etc.; e.g. "Jasmin Patry" -> Jasmin Patry
  38.     eval "set name $name"
  39.     eval "set author $author"
  40.     eval "set par_time $par_time"
  41.  
  42.     return [list $name $author $par_time];
  43. }
  44.  
  45. set cwd [pwd]
  46. tux_goto_data_dir
  47.  
  48. tux_load_texture noicon textures/noicon.rgb
  49.  
  50. cd courses
  51.  
  52. tux_load_texture no_preview common/nopreview.rgb
  53. tux_bind_texture no_preview no_preview
  54.  
  55. #
  56. # Bind preview textures if they exist
  57. #
  58. foreach course [glob -nocomplain *] {
  59.     if { $course == "common" || $course == "contrib" } {
  60.     continue;
  61.     }
  62.     if [file exists "$course/preview.rgb"] {
  63.     tux_load_texture $course "$course/preview.rgb"
  64.     tux_bind_texture $course $course
  65.     }
  66. }
  67.  
  68. cd contrib;
  69.  
  70. foreach course [glob -nocomplain *] {
  71.     if [file exists "$course/preview.rgb"] {
  72.     tux_load_texture "contrib/$course" "$course/preview.rgb"
  73.     tux_bind_texture "contrib/$course" "contrib/$course"
  74.     }
  75. }
  76.  
  77. cd ..
  78.  
  79. #
  80. # Build list of contributed courses in contrib
  81. #
  82. cd contrib
  83. set contrib_course_list {}
  84. foreach course [glob -nocomplain *] {
  85.     if { $course == "CVS" } {
  86.     continue;
  87.     }
  88.  
  89.     if [catch {cd $course}] {
  90.     puts stderr "Couldn't change directory to $course"
  91.     continue;
  92.     }
  93.  
  94.     set course_info [get_course_info]
  95.  
  96.     cd ..
  97.  
  98.     set description "Contributed by: [lindex $course_info 1]"
  99.     
  100.     lappend contrib_course_list \
  101.         [list -course "contrib/$course" -name [lindex $course_info 0] \
  102.         -description $description -par_time [lindex $course_info 2] ] 
  103. }
  104. cd ..
  105.  
  106. tux_open_courses [concat \
  107.     { \
  108.     { \
  109.         -course frozen_river -name "Frozen River" \
  110.             -description "Keep your speed down to collect herring!" \
  111.                     -par_time 80.0 \
  112.     } \
  113.     { \
  114.         -course path_of_daggers -name "Path of Daggers" \
  115.             -description "Big spikes may prove to be the least of your worries on this course.  Muliple paths allow you to take low or high roads, each with their own challenges." \
  116.                     -par_time 70.0 \
  117.     } \
  118.     { \
  119.         -course bunny_hill -name "Bunny Hill" \
  120.             -description "Use clever turning to conquer the Bunny Hill." \
  121.                     -par_time 40.0 \
  122.     } \
  123.     { \
  124.         -course twisty_slope -name "Twisty Slope" \
  125.             -description "Tight twists make grabbing herring difficult.  Hard turns will lead you to victory." \
  126.                     -par_time 40.0 \
  127.     } \
  128.     { \
  129.         -course bumpy_ride -name "Bumpy Ride" \
  130.             -description "This hill has a series of ramps tackle.  Make sure to line yourself up before getting airborne." \
  131.                     -par_time 40.0 \
  132.     } \
  133.     } \
  134.     $contrib_course_list \
  135. ]
  136.  
  137. tux_load_texture herring_run_icon common/herringrunicon.rgb 0
  138. tux_load_texture cup_icon common/cupicon.rgb 0
  139.  
  140. tux_events {
  141.     { 
  142.     -name "Herring Run" -icon herring_run_icon -cups {
  143.         { 
  144.         -name "Canadian Cup" -icon cup_icon -races {
  145.             {
  146.             -course bunny_hill \
  147.                 -name "Bunny Hill" \
  148.                 -description "Use clever turning to conquer the Bunny Hill." \
  149.                 -herring { 23 23 23 23 } \
  150.                 -time { 37 35 32 30 } \
  151.                 -score { 0 0 0 0 } \
  152.                 -mirrored no -conditions sunny \
  153.                 -windy no -snowing no
  154.             }
  155.             {
  156.             -course twisty_slope \
  157.                 -name "Twisty Slope" \
  158.                 -description "Tight twists make grabbing herring difficult.  Hard turns will lead you to victory." \
  159.                 -herring { 24 24 24 24 } \
  160.                 -time { 43 40 34 31.5 } \
  161.                 -score { 0 0 0 0 } \
  162.                 -mirrored no -conditions sunny \
  163.                 -windy no -snowing no
  164.             }
  165.             {
  166.             -course bumpy_ride \
  167.                 -name "Bumpy Ride" \
  168.                 -description "This hill has a series of ramps tackle.  Make sure to line yourself up before getting airborne." \
  169.                 -herring { 18 18 18 18 } \
  170.                 -time { 35 30 28 27 } \
  171.                 -score { 0 0 0 0 } \
  172.                 -mirrored no -conditions sunny \
  173.                 -windy no -snowing no
  174.             }
  175.         }
  176.         }
  177.     }
  178.     }
  179. }
  180.     
  181.  
  182. cd $cwd
  183.  
  184.